<template>
    <div id="OrdersTitle">
        <v-details :inputConfig="inputConfig" :detailData="inputData" :rules="rules" ref="input" @changeData="changeData"></v-details>

        <v-table
                :searchFlag="false"
                :hasEdit="false"
                :pageSize="pageSize"
                :page="page"
                :tableConfig="tableConfig"
                :tableData="tableData"
                :total="total"
                @findData="getTableData"
                @getTableData="getTableData"
                @searhData="setSearhData"
                @selectData="setSelectData"
                @upData="getTableData"
                ref="table"
        ></v-table>
    </div>
</template>

<script>
    import details from 'commons/Detail'
    import baseMixin from "@/mixins/BaseMixin";
    import table from "commons/Table";

    export default {
        props: {
            inputData: {
                type: Object,
            }
        },
        mixins: [baseMixin],
        name: "OrdersTitle",
        data() {
            return {
                tableConfig: [
                    {
                        label: this.$t('common.status'),
                        prop: "statusdescr",
                        input: "input",
                    },
                    {
                        label: this.$t('wave.units'),
                        prop: "units",
                        input: "input",
                    },
                    {
                        label: this.$t('wave.percentval'),
                        prop: "percentval",
                        input: "input",
                    }
                ],
                tableData: [],
              page: 1,
                pageSize: 10,
                total: 10,
                searhData: {}
            }
        },
        computed: {
            inputConfig() {
                return [
                    [
                        {
                            type: "input",
                            label: this.$t('out.wavekey'),
                            props: "wavekey",
                            disabled: true
                        }
                    ],
                    [
                        {
                            type: "select",
                            label: this.$t('wave.wdisptype'),
                            props: "wdisptype",
                            options: this.getOptions("querycodeLkup/WDISPTYPE")
                        }
                    ],
                    [
                        {
                            type: "input",
                            label: this.$t('common.desc'),
                            props: "description",
                            disabled: true
                        }
                    ],
                ]

            },
            rules() {
                return {
                    wavekey: [
                        {required: true, trigger: 'blur'},
                    ],
                    status: [
                        {required: true, trigger: 'blur'},
                    ],
                    adddate: [
                        {required: true, trigger: 'blur'},
                    ],
                    sumtotalorders: [
                        {required: true, trigger: 'blur'},
                    ]
                }
            }
        },
        methods: {
            changeData(data) {
                this.$parent.updata = data;
            },
            //获取table数据
            async getTableData(page, data) {
                try {
                    let res = await this.$api.get(`/queryWpWavestatusListByWavekey/${this.inputData.wavekey}/${page}`);
                    
                        this.loading = false;
                        this.tableData = res.page.list;
                      this.page = res.page.curpage;
                        this.pageSize = res.page.pageSize;
                        this.total = res.page.total;
                    
                } catch (e) {
                    this.$message.error(e);
                }
            },
            //搜索值
            setSearhData(data, up) {
                if (!up) {
                    this.searhData = data;
                } else {
                    this.searhData = data;
                    this.getTableData(1, this.searhData);
                }
            },
            //选中的数据
            setSelectData(data) {
                this.$parent.setSelectData(data)
            },
        },
        mounted() {
            this.getTableData(1, {})
        },
        watch: {},
        components: {
            'v-details': details,
            'v-table': table
        }
    }
</script>

<style scoped>

</style>
